package controller;

import exception.MyException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import service.TestExceptionService;

import java.sql.SQLException;

@Controller
//public class TestExceptionController extends BaseController{
public class TestExceptionController {
    @Autowired
    private TestExceptionService service;

    @GetMapping("/daodb")
    public void daodb() throws SQLException{
        service.daodb();
    }

    @GetMapping("/daomy")
    public void daomy() throws MyException{
        service.daomy();
    }

    @GetMapping("/daono")
    public void daono() throws Exception{
        service.daono();
    }

    @GetMapping("/servicedb")
    public void servicedb() throws SQLException{
        service.servicedb();
    }

    @GetMapping("/servicemy")
    public void servicemy() throws MyException{
        service.servicemy();
    }

    @GetMapping("/serviceno")
    public void serviceno() throws Exception{
        service.serviceno();
    }

    @GetMapping("/db")
    public void db() throws SQLException{
        throw new SQLException("Controller中数据库异常");
    }

    @GetMapping("/my")
    public void my() throws MyException{
        throw new MyException("Controller中自定义异常");
    }

    @GetMapping("/no")
    public void no() throws Exception{
        throw new Exception("Controller中未知异常");
    }

}
